package com.har.modules.business.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.har.common.utils.PageUtils;
import com.har.common.utils.Query;
import com.har.modules.business.dao.TFinanceProductDao;
import com.har.modules.business.entity.TFinanceProductEntity;
import com.har.modules.business.service.TFinanceProductService;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("tFinanceProductService")
public class TFinanceProductServiceImpl extends ServiceImpl<TFinanceProductDao, TFinanceProductEntity> implements TFinanceProductService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

      EntityWrapper<TFinanceProductEntity> ew = new EntityWrapper<TFinanceProductEntity>();

        if(params.get("productName") != null  && params.get("productName").toString().length() != 0){
            ew.like("product_name","%"+params.get("productName")+"%");
        }
        if(params.get("type") != null  && params.get("type").toString().length() != 0){
            ew.eq("type",params.get("type"));
        }
        if(params.get("status") != null  && params.get("status").toString().length() != 0){
            ew.eq("status",params.get("status"));
        }
        ew.eq("product_type",params.get("productType"));
        ew.orderBy("UPDATE_TIME DESC");

        Page<TFinanceProductEntity> page = this.selectPage(
                new Query<TFinanceProductEntity>(params).getPage(),ew);
        return new PageUtils(page);
    }

}
